#!/bin/bash
set -e

function do_test {
  OUT=`mktemp`
  test/regress "${srcdir}/test/media/$1" $2 > $OUT
  diff --unified --strip-trailing-cr "${srcdir}/test/media/$1.ok" $OUT
  rm $OUT
}

# Test parsing.
# New additions to media/ should be included here and in the -r section.
do_test seek.webm
do_test bug603918.webm
do_test detodos.webm
do_test split.webm
do_test demo_short.webm
do_test seek_sub.webm
do_test dancer1.webm
do_test dancer1rb.webm
do_test seek_encrypted.webm
do_test subsample_encrypted.webm
do_test bug1480003.webm
do_test bug1539686.webm
do_test bug1592193.webm

# Test resumable parsing by forcing fake EOFs every byte.
do_test seek.webm -r
do_test bug603918.webm -r
do_test detodos.webm -r
do_test split.webm -r
do_test demo_short.webm -r
do_test seek_sub.webm -r
do_test dancer1.webm -r
do_test dancer1rb.webm -r
do_test seek_encrypted.webm -r
do_test subsample_encrypted.webm -r
do_test bug1480003.webm -r
do_test bug1539686.webm -r
do_test bug1592193.webm -r

# Pass file size to nestegg_init as max_offset.
# This is a hack to test with a specific truncated file.
do_test bug1200148.webm -l
